package com.company.project.controller.ldjsc.snct;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.company.project.entity.ldjsc.smzt.JscSmztYlfwEntity;
import com.company.project.entity.ldjsc.snct.JscSnctNyncjjzbEntity;
import com.company.project.service.ldjsc.snct.JscSnctNyncjjzbService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.company.project.common.utils.DataResult;





/**
 *
 *
 * @author wenbin
 * @email *****@mail.com
 * @date 2025-08-19 15:11:16
 */
@Controller
@RequestMapping("/sxzy")
public class JscSnctNyncjjzbController {
    @Autowired
    private JscSnctNyncjjzbService jscSnctNyncjjzbService;


    @ApiOperation(value = "农业农村经济指标")
    @GetMapping("/jsc-dd-zt/JscNyncjjzb2")
    @ResponseBody
    public DataResult findListByPage(JscSnctNyncjjzbEntity jscSnctNyncjjzb){
        LambdaQueryWrapper<JscSnctNyncjjzbEntity> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(JscSnctNyncjjzbEntity::getAscription, jscSnctNyncjjzb.getAscription());
        queryWrapper.orderByDesc(JscSnctNyncjjzbEntity::getYear);
        queryWrapper.orderByDesc(JscSnctNyncjjzbEntity::getTime_value);
        queryWrapper.orderByDesc(JscSnctNyncjjzbEntity::getId);

        if (jscSnctNyncjjzb.getMidgard_offset() != null){
            jscSnctNyncjjzb.setMidgard_page(1);
        }
        IPage<JscSnctNyncjjzbEntity> iPage = jscSnctNyncjjzbService.page(jscSnctNyncjjzb.getQueryPage(), queryWrapper);
        List<JscSnctNyncjjzbEntity> records = iPage.getRecords();


        // 构造所需的数据结构
        List<String> columnNames = Arrays.asList(
                "id", "data_index", "refine_name", "ascription", "num1", "num2", "num3",
                "num4", "num5", "num6", "num7", "num8", "num9", "num10", "num11",
                "time_type", "time_value", "year", "source", "admin_dis", "update_time"
        );

        Map<String, Object> result = new HashMap<>();
        result.put("columnNames", columnNames);
        result.put("value", records);

        return DataResult.success(result);
    }



}
